/******************************************************************
 * Copyright @ 2023 广州牛师帮科技文化有限公司. All rights reserverd.
 * @file   src\utils\RGBA.ts
 * @author 朱剑豪
 * @date   2023/10/23 14:40
 * @desc   颜色类
 ******************************************************************/

export class RGBA {
  r: number
  g: number
  b: number
  a: number
  constructor(r: number, g: number, b: number, a: number) {
    this.r = Math.floor(r)
    this.g = Math.floor(g)
    this.b = Math.floor(b)
    this.a = a
  }
  copy(): RGBA {
    return new RGBA(this.r, this.g, this.b, this.a)
  }
  setAlpha(a: number): this {
    this.a = a
    return this
  }
  get rgba() {
    return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`
  }
}